package com.demo.dao;


import com.demo.pojo.Subitem;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @ClassName Subitem
 * @Description TODO
 * @Author Windy
 * @Date 2022/8/25 14:31
 * @Version 1.0
 **/
public interface SubitemDao {

    ////通过pid查询数据，并获取其对应关系中的数据
    @Select("select * from subitem where pid=#{pid} and status=1")
    @Results(id = "subitemMap",value = {
            @Result(column = "suid",property = "suid"),
            @Result(column = "sname",property = "sname"),
            @Result(column = "starttime",property = "starttime"),
            @Result(column = "endtime",property = "endtime"),
            @Result(column = "pid",property = "pid"),
            @Result(column = "updatetime",property = "updatetime"),
            @Result(column = "status",property = "status"),
//            一对多（子项工程）
            @Result(column = "suid",property = "items",
                many = @Many(select = "com.demo.dao.ItemDao.findItemsBySuid")
            )
    })
    List<Subitem> findSubitemsAndItems(int pid);

}
